<?php

namespace Admin\Models\ims;
use Admin\Models\BaseModel;
use Helpers\Main;

class XHImsProduceIn extends BaseModel
{

    /**
     *
     * @var integer
     * @Primary
     * @Identity
     * @Column(type="integer", length=11, nullable=false)
     */
    public $iPInId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iProdId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iInType;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iInTypeId;

    /**
     *
     * @var string
     * @Column(type="string", length=20, nullable=true)
     */
    public $sMeasure;

    /**
     *
     * @var string
     * @Column(type="string", length=100, nullable=true)
     */
    public $sSize;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iCIId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iInNum;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tInTime;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tProdStart;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tProdEnd;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iSchoolId;

    /**
     *
     * @var double
     * @Column(type="double", length=10, nullable=true)
     */
    public $dInPrice;


    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $mDesc;

    /**
     *
     * @var integer
     * @Column(type="integer", length=4, nullable=true)
     */
    public $bDelete;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tCreateDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tLastModifyDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iLastModifyUserId;

    /**
     * 2.学生机 3.教师机 4.备用机 5.公用机 6.自用机
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iDevType;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        parent::initialize();
        $this->setSchema("xh_webmanage");
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XHImsProduceIn[]|XHImsProduceIn|\Phalcon\Mvc\Model\ResultSetInterface
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XHImsProduceIn
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHIms_ProduceIn';
    }

    /**
     * 新建之前的操作
     *
     * @return bool|void
     * create by xjq 20180621
     */
    public function beforeCreate()
    {
        $date = date('Y-m-d H:i:s', time());
        $id   = Main::getLoginUserInfo('userId');
        $this->tCreateDate   = $date;
        $this->iCreateUserId = $this->iCreateUserId ?: $id;
        $this->tLastModifyDate = $date;
        $this->iLastModifyUserId = $this->iLastModifyUserId ?: $id;
    }

}
